(compilation-directory): New defvar.
authorEli Zaretskii <eliz@is.elta.co.il>
Mon, 16 Feb 2004 12:50:24 +0000 (12:50 +0000)
committerEli Zaretskii <eliz@is.elta.co.il>
Mon, 16 Feb 2004 12:50:24 +0000 (12:50 +0000)
(compile): Save current directory in compilation-directory.
(recompile): Bind default-directory to compilation-directory if
that is non-nil.

lisp/progmodes/compile.el

index de050411411f0991a1f3f9f79cb9e7958696d365..5f9ffbf2c33c1739f571408da436b5ee4d2ec175 100644 (file)
@@ -386,6 +386,9 @@ If any FILE-FORMAT is given, each is a format string to produce a file name to
 try; %s in the string is replaced by the text matching the FILE-IDX'th
 subexpression.")
 
+(defvar compilation-directory nil
+  "Directory to restore to when doing `recompile'.")
+
 (defvar compilation-enter-directory-regexp-alist
   '(
     ;; Matches lines printed by the `-w' option of GNU Make.
@@ -578,6 +581,7 @@ to a function that generates a unique name."
   (unless (equal command (eval compile-command))
     (setq compile-command command))
   (save-some-buffers (not compilation-ask-about-save) nil)
+  (setq compilation-directory default-directory)
   (compile-internal command "No more errors"))
 
 ;; run compile with the default command line
@@ -587,8 +591,10 @@ If this is run in a compilation-mode buffer, re-use the arguments from the
 original use.  Otherwise, it recompiles using `compile-command'."
   (interactive)
   (save-some-buffers (not compilation-ask-about-save) nil)
-  (apply 'compile-internal (or compilation-arguments
-                             `(,(eval compile-command) "No more errors"))))
+  (let ((default-directory (or compilation-directory default-directory)))
+    (apply 'compile-internal (or compilation-arguments
+                                `(,(eval compile-command)
+                                  "No more errors")))))
 
 (defcustom compilation-scroll-output nil
   "*Non-nil to scroll the *compilation* buffer window as output appears.